{% extends "base.html" %}

{% block content %}
  <script type="text/javascript">
    window.onload=function() {
      document.add_new_message.message.focus();
    }
  </script>
  <center>
  {% if is_admin %}
    <h2>Enter Builder Status</h2>
    <br/>
    <form action="/builder-status" name="add_new_message" method="post">
      <table>
        <tr>
          <td>Builder name</td>
          <td>
            <input type="text" size="80" name="builder_name" value="{{ selected_builder_name }}">
          </td>
        </tr>
        <tr>
          <td>Status message</td>
          <td>
            <input type="text" size="80" name="message" value="{{ selected_builder_status }}">
          </td>
        </tr>
      </table>
      <input type="submit" name="submit" value="Submit">
      <input type="button" name="refresh" value="Refresh" onclick="location.href='/builder-status';">
    </form>
    {% if selected_builder_status %}
    <form action="/builder-status" name="delete_builder_status" method="post">
      <input type='hidden' name='delete' value='{{ selected_builder_name }}'>
      <input type='submit' value='Delete'{% if not is_admin %} disabled {% endif %}>
    </form>
    {% endif %}

    <br/>
    Builder status messages support HTML.<br/>
    Entering a status message for a builder that already has one will replace the old message.
  {% endif %}
  <br/><br/><br/><hr/>
  <h2>Current {{ title }}</h2>
  <br/>
  <table border="1" cellpadding="5">
  <tr bgcolor="#CCCCFF">
    <td><b>Builder</b></td>
    <td><b>Who</b></td>
    <td><b>When</b></td>
    <td><b>Message</b></td>
    <td><b>Delete</b></td>
  </tr>
  {% for a_status in builder_statuses %}
    <tr>
      <td>{{ a_status.builder_name }}</td>
      <td>{{ a_status.username }}</td>
      <td>{{ a_status.date|date:"D M d, H:i T " }}</td>
      <td>{{ a_status.message }}</td>
      <td align="center">
        <form action="/builder-status" name="delete_builder_status" method="post">
          <input type='hidden' name='delete' value='{{ a_status.builder_name }}'>
          <input type='submit' value='Delete'{% if not is_admin %} disabled {% endif %}>
        </form>
      </td>
    </tr>
  {% endfor %}

  </table>
  </center>
{% endblock %}
